Fox's Git Mirrors
Node / rns-mirrors / Reticulum-Go.git / files / examples / wasm / vendor / github.com / quic-go / quic-go / internal / wire / pool.go
Displaying Raw • Download
examples/wasm/vendor/github.com/quic-go/quic-go/internal/wire/pool.go 633735d797cc5f5d48cb2e22e8fd7cd743930daf (633735d7) Text, 557 B
package wire
import (
"sync"
"github.com/quic-go/quic-go/internal/protocol"
)
var pool sync.Pool
func init() {
pool.New = func() any {
return &StreamFrame{
Data: make([]byte, 0, protocol.MaxPacketBufferSize),
fromPool: true,
}
}
}
func GetStreamFrame() *StreamFrame {
f := pool.Get().(*StreamFrame)
return f
}
func putStreamFrame(f *StreamFrame) {
if !f.fromPool {
return
}
if protocol.ByteCount(cap(f.Data)) != protocol.MaxPacketBufferSize {
panic("wire.PutStreamFrame called with packet of wrong size!")
}
pool.Put(f)
}
Served by rngit 1.5.2 - Generated in 0.02s